package com;
import java.sql.*;
import java.util.*;

public class GetUserList {
	 DBcon db=new DBcon();
	 ResultSet rs = null;
	 String sql ="";
	 ArrayList<User> userList = new ArrayList<User>();
	 public ArrayList<User> GetList()
	 {
		 sql = "select *from user";
		 rs=db.Query(sql);
		 try {
			while (rs.next()) {
			        User user = new User();
			        user.setUsername(rs.getString("username"));
			        user.setPassword(rs.getString("password"));
			        user.setType("用户");
			        userList.add(user);
			    }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 sql = "select *from admin";
		 rs=db.Query(sql);
		 try {
			while (rs.next()) {
			        User user = new User();
			        user.setUsername(rs.getString("username"));
			        user.setPassword(rs.getString("password"));
			        user.setType("管理员");
			        userList.add(user);
			    }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return userList;
	 }

}
